package thread;
/**
 * 当一个线程调用sleep()处于睡眠阻塞的过程中若该线程的interrupt方法被调用,
 * 则会打断其睡眠阻塞状态,此时sleep()会抛出中断异常:InterruptedException*/
public class sleepDemo2 {
    public static void main(String[] args) {
        Thread lin  = new Thread("李永健"){
            @Override
            public void run() {
                System.out.println(getName()+":开始睡觉了!(*^▽^*)");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    System.out.println(getName()+":吵到我了!!![○･｀Д´･ ○]");
                }
                System.out.println(getName()+":睡醒了ヾ(๑╹◡╹)ﾉ\"");
            }
        };
        lin.start();
        Thread huang = new Thread("黄大锤"){
            @Override
            public void run() {
                System.out.println(getName()+":我开始干活了!(≖ᴗ≖)✧");
                for (int i = 0; i < 5; i++) {
                    System.out.println(getName()+":敲墙✺◟(∗❛ัᴗ❛ั∗)◞✺");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(getName()+":我干完了,给钱o(￣▽￣)ｄ ");
                lin.interrupt();//中断lin进程的睡眠
            }
        };
        huang.start();

    }
}
